<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        li {
            list-style-type: none;
        }

        /* a {
            text-decoration: none;
            font-size: 14px;
        } */

        .menu {
            height: 25px;
            width: 300px;
            margin: 200px auto;
            background-color: #ccc;
        }

        .menu>li {
            width: 50px;
            height: 25px;
            position: relative;
            float: left;
            margin: 0 10px;
        }

        .menu li a {
            text-decoration: none;
            color: #000;
            font-size: 16px;
            font-weight: 600;
        }

        .items {
            margin-top: 4px;
            position: absolute;
            display: none;
        }

        .items li {
            width: 40px;
            height: 30px;
            border: #000 1px solid;
            padding: 0 5px;

        }

        .appear {
            display: block;
        }
    </style>
</head>

<body>
    <ul class="menu">
        <li>
            <a href="">微博</a>
            <ul class="items">
                <li>私信</li>
                <li>评论</li>
                <li>@我</li>
            </ul>
        </li>
        <li>
            <a href="">微博</a>
            <ul class="items">
                <li>私信</li>
                <li>评论</li>
                <li>@我</li>
            </ul>
        </li>
        <li>
            <a href="">微博</a>
            <ul class="items">
                <li>私信</li>
                <li>评论</li>
                <li>@我</li>
            </ul>
        </li>
    </ul>
</body>
<script>
    var menu = document.querySelector('.menu');
    console.dir(menu);
    var lis = menu.children;
    for (var i = 0; i < lis.length; i++) {
        lis[i].onmouseover = function () {
            // console.log(1);
            this.style.backgroundColor = "#c0c";
            this.querySelector('ul').className = 'items appear';
        }
        lis[i].onmouseleave = function () {
            for (var i = 0; i < lis.length; i++) {
                this.style.backgroundColor = "#ccc";
                this.querySelector('ul').className = 'items';
            }
        }
    }
</script>

</html>